package net.hvacapp.cmvrfforandroid.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import net.hvacapp.cmvrfforandroid.R;

/**
 * Created by zhangnorman on 15/7/23.
 */
public class GroupSelectionView extends RelativeLayout {
    private RelativeLayout mUserSelectionLl;
    private TextView mTitleTv;
    private TextView mSelectionInfoTv;
    private ImageView mImageIv;

    public GroupSelectionView(Context context) {
        super(context);
        init(context, 0);
    }

    public GroupSelectionView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, 0);
    }

    public GroupSelectionView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, defStyle);
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        mUserSelectionLl.setOnClickListener(onClickListener);
    }

    public void setTitleString (String title) {
        mTitleTv.setText(title);
    }

    public void setInfoString (String info) {
        mSelectionInfoTv.setText(info);
    }

    public void setGroupVisible (boolean visible) {
        if (visible) {
            mImageIv.setImageResource(R.drawable.arrow_up);
        }
        else {
            mImageIv.setImageResource(R.drawable.arrow_down);
        }
    }

    private void init(Context context, int defStyle) {
        LayoutInflater.from(context).inflate(R.layout.view_group_selection, this,
                true);
        mTitleTv = (TextView) findViewById(R.id.tv_title);
        mSelectionInfoTv = (TextView) findViewById(R.id.tv_info);
        mUserSelectionLl = (RelativeLayout) findViewById(R.id.ll_user_selection);
        mImageIv = (ImageView) findViewById(R.id.iv_selection_hint);
    }


}
